package com.example.task11v27window;

import java.net.URL;
import java.time.Instant;
import java.time.LocalDate;
import java.util.Date;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class HelloController {

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private DatePicker dateDP;

    @FXML
    private TextField patternTF;

    @FXML
    private Label resLabel;

    @FXML
    private Button solveBtn;

    @FXML
    void solveClick(ActionEvent event) {
        String pattern = patternTF.getText();
        LocalDate date = dateDP.getValue();
        resLabel.setText(DateFormatter.formatDate(date,pattern));
    }

    @FXML
    void initialize() {
        assert dateDP != null : "fx:id=\"dateDP\" was not injected: check your FXML file 'hello-view.fxml'.";
        assert patternTF != null : "fx:id=\"patternTF\" was not injected: check your FXML file 'hello-view.fxml'.";
        assert resLabel != null : "fx:id=\"resLabel\" was not injected: check your FXML file 'hello-view.fxml'.";
        assert solveBtn != null : "fx:id=\"solveBtn\" was not injected: check your FXML file 'hello-view.fxml'.";
    }
}